// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import Axios from 'axios'
import sdk from './wxsdk/sdk.js' //引入sdk.js

router.beforeEach((to, from, next) => {
    if (to.path == '/match/detail/MatchDetailGoing' || to.path == '/have' || to.path == '/match/apply') {
        if (to.path == '/match/detail/MatchDetailGoing') {
            let url = window.location.href.split('#')[0];
            let obj = {
                title: 'TISSYS-网球赛事服务系统', //分享标题
                desc: '专业、高效、稳定的赛事一体化智能软件服务系统，旨在为赛事各参与方提供的全流程一体化智能解决方案。', //分享内容
                linkurl: location.protocol + '//' + location.host + '/mobile/#' + window.location.href.split('#')[1], //分享链接
                img: 'http://www.tissys.com/default_logo.png' //分享内容显示的图片
            }
            sdk.getJSSDK(url, obj) //传入sdk.js需要的参数
        }
        next()
    } else {
        let url = window.location.href.split('#')[0];
        let obj = {
            title: 'TISSYS-网球赛事服务系统', //分享标题
            desc: '专业、高效、稳定的赛事一体化智能软件服务系统，旨在为赛事各参与方提供的全流程一体化智能解决方案。', //分享内容
            linkurl: location.protocol + '//' + location.host + '/mobile/#' + to.fullPath, //分享链接
            img: 'http://www.tissys.com/default_logo.png' //分享内容显示的图片
        }
        sdk.getJSSDK(url, obj) //传入sdk.js需要的参数
        next()
    }
})
// 返回键链接
export const HOST = 'http://www.tissys.com/'//正式服
// export const HOST = 'http://tennis.laigl.com/'//测试服
// 打包环境
Axios.defaults.baseURL = 'http://www.tissys.com/' //正式服
// Axios.defaults.baseURL = 'http://tennis.laigl.com/' //测试服
// Axios.defaults.baseURL = '/' //测试服
// Axios.defaults.baseURL = 'http://test.tissys.com/' //正式服务器测试环境
if (window.location.href.indexOf('code')!=-1) {
	//有code
	if(window.location.href.indexOf('club_id')!=-1){
		// 机构链接
		sessionStorage.setItem('club_id',window.location.href.split('=')[3])//浏览器为1 微信环境为3
	}else{
		// 不是机构链接
		sessionStorage.setItem('club_id','undefined') 
	}
	
} else{
	// 无code
	if(window.location.href.indexOf('club_id')!=-1){
		// 机构链接
		sessionStorage.setItem('club_id',window.location.href.split('=')[1])//浏览器为1 微信环境为3
	}else{
		// 不是机构链接
		sessionStorage.setItem('club_id','undefined')
	}
}
Vue.prototype.$axios = Axios
    /*vant*/
import Vant from 'vant';
import { Icon } from 'vant';
import 'vant/lib/index.css';
Vue.use(Vant);
Vue.use(Icon)
/*header&footer&adbox*/
import HeaderCom from '@/components/header'
import FooterCom from '@/components/footer'
import AdBox from '@/components/adBox'
import BannerCom from '@/components/banner'
Vue.component('footer-com', FooterCom)
Vue.component('header-com', HeaderCom)
Vue.component('ad-box', AdBox)
Vue.component('banner-com', BannerCom)
    /**/
    /*match*/
import BattleCom from '@/components/match/battle'
Vue.component('battle-com', BattleCom)
    /**/
Vue.config.productionTip = false

//滑块
import 'swiper/dist/css/swiper.css'
// import VueAwesomeSwiper from 'vue-awesome-swiper'
// Vue.use(VueAwesomeSwiper)

//socket
import VueSocketio from 'vue-socket.io';
import socketio from 'socket.io-client';
// Vue.use(VueSocketio, socketio('http://47.104.64.239:8080/'));

//echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
    // Vue.use(myCharts)

import Mint from 'mint-ui';
Vue.use(Mint);
import 'mint-ui/lib/style.css';

//权限控制
import './router/power.js';

//vue-scroller 分页插件
import VueScroller from 'vue-scroller'
Vue.use(VueScroller)

// 直播
import VueVideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
Vue.use(VueVideoPlayer)

//weilang2019-3-2引入
// import 'babel-polyfill'
// import Es6Promise from 'es6-promise'
// require('es6-promise').polyfill()
// Es6Promise.polyfill()

/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    components: {
        App
    },
    template: '<App/>'
})
